home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / ctutor2 / ifelse.c < prev    next >
Text File  |  1985-12-20  |  512b  |  19 lines

  1. /* This is an example of the if and the if-else statements */
  2.  
  3. main()
  4. {
  5. int data;
  6.  
  7.    for(data = 0;data < 10;data = data + 1) {
  8.  
  9.       if (data == 2)
  10.          printf("Data is now equal to %d\n",data); 
  11.  
  12.       if (data < 5)
  13.          printf("Data is now %d, which is less than 5\n",data);
  14.       else
  15.          printf("Data is now %d, which is greater than 4\n",data);
  16.            
  17.    }  /* end of for loop */
  18. }
  19.